import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index")
      }
    ]
  },
  {
    path: "/login",
    component: () => import("@/views/login/index"),
    hidden: true
  },
  {
    path: "/auth-redirect",
    component: () => import("@/views/login/auth-redirect"),
    hidden: true
  },
  {
    path: "/404",
    component: () => import("@/views/error-page/404"),
    hidden: true
  },
  {
    path: "/401",
    component: () => import("@/views/error-page/401"),
    hidden: true
  },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        component: () => import("@/views/dashboard/index"),
        name: "dashboard",
        meta: { title: "首页", icon: "dashboard", affix: true }
      }
    ]
  },

  {
    path: "/profile",
    component: Layout,
    redirect: "/profile/index",
    hidden: true,
    children: [
      {
        path: "index",
        component: () => import("@/views/profile/index"),
        name: "Profile",
        meta: { title: "Profile", icon: "user", noCache: true }
      }
    ]
  }
];

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: "/error",
    component: Layout,
    redirect: "noRedirect",
    name: "ErrorPages",
    meta: {
      title: "Error Pages",
      icon: "404"
    },
    hidden: true,
    children: [
      {
        path: "401",
        component: () => import("@/views/error-page/401"),
        name: "Page401",
        meta: { title: "401", noCache: true }
      },
      {
        path: "404",
        component: () => import("@/views/error-page/404"),
        name: "Page404",
        meta: { title: "404", noCache: true }
      }
    ]
  },

  {
    path: "/admin",
    component: Layout,
    redirect: "/admin/user",
    meta: {
      title: "管理员",
      icon: "users",
      roles: ["adminuserlist", "authoritycategorylist", "rolelist"]
    },
    children: [
      {
        path: "authority-category",
        name: "authorityCategoryList",
        component: () => import("@/views/authority_category/index"),
        meta: {
          title: "权限分类列表",
          activeMenu: "/admin/authority-category",
          roles: ["authoritycategorylist"]
        }
      },
      {
        path: "authority-category/create",
        name: "authorityCategoryCreate",
        component: () => import("@/views/authority_category/create"),
        meta: {
          title: "添加权限分类",
          activeMenu: "/admin/authority-category",
          roles: ["authoritycategorycreate"]
        },
        hidden: true
      },
      {
        path: "authority-category/edit/:id(\\d+)",
        component: () => import("@/views/authority_category/edit"),
        name: "authorityCategoryEdit",
        meta: {
          title: "修改权限分类",
          activeMenu: "/admin/authority-category",
          roles: ["authoritycategoryedit"]
        },
        hidden: true
      },
      {
        path: "role",
        name: "roleList",
        component: () => import("@/views/role/index"),
        meta: {
          title: "角色列表",
          activeMenu: "/admin/role",
          roles: ["rolelist"]
        }
      },
      {
        path: "role/create",
        name: "roleCreate",
        component: () => import("@/views/role/create"),
        meta: {
          title: "添加角色",
          activeMenu: "/admin/role",
          roles: ["rolecreate"]
        },
        hidden: true
      },
      {
        path: "role/edit/:id(\\d+)",
        component: () => import("@/views/role/edit"),
        name: "roleEdit",
        meta: {
          title: "修改角色",
          activeMenu: "/admin/role",
          roles: ["roleedit"]
        },
        hidden: true
      },
      {
        path: "authority",
        name: "authorityList",
        component: () => import("@/views/authority/index"),
        meta: {
          title: "权限列表",
          activeMenu: "/admin/authority",
          roles: ["authoritylist"]
        }
      },
      {
        path: "authority/create",
        name: "authorityCreate",
        component: () => import("@/views/authority/create"),
        meta: {
          title: "添加权限",
          activeMenu: "/admin/authority",
          roles: ["authoritycreate"]
        },
        hidden: true
      },
      {
        path: "authority/edit/:id(\\d+)",
        component: () => import("@/views/authority/edit"),
        name: "authorityEdit",
        meta: {
          title: "修改权限",
          activeMenu: "/admin/authority",
          roles: ["authorityedit"]
        },
        hidden: true
      },
      {
        path: "user",
        name: "adminUser",
        component: () => import("@/views/admin/index"),
        meta: {
          title: "管理员列表",
          activeMenu: "/admin/user",
          roles: ["adminuserlist"]
        }
      },
      {
        path: "user/create",
        name: "adminUserCreate",
        component: () => import("@/views/admin/create"),
        meta: {
          title: "添加管理员",
          activeMenu: "/admin/user",
          roles: ["adminusercreate"]
        },
        hidden: true
      },
      {
        path: "user/edit/:id(\\d+)",
        component: () => import("@/views/admin/edit"),
        name: "adminUserEdit",
        meta: {
          title: "修改管理员",
          activeMenu: "/admin/user",
          roles: ["adminuseredit"]
        },
        hidden: true
      }
    ]
  },
  
  {
    path: "/admin/trends",
    component: Layout,
    redirect: "/admin/trends/list",
    meta: {
      title: "动态",
      icon: "university",
      roles: ["admintrendslist"]
    },
    children: [
      {
        path: "list",
        name: "trendsList",
        component: () => import("@/views/trends/index"),
        meta: {
          title: "动态列表",
          activeMenu: "/admin/trends/list",
          roles: ["admintrendslist"]
        }
      }
    ]
  },
  
  {
    path: "/admin/major",
    component: Layout,
    redirect: "/admin/major/list",
    meta: {
      title: "专业",
      icon: "major",
      roles: ["adminmajorcategorylist"]
    },
    children: [
      {
        path: "category/list",
        name: "majorCategoryList",
        component: () => import("@/views/major_category/index"),
        meta: {
          title: "专业分类列表",
          activeMenu: "/admin/major/category/list",
          roles: ["adminmajorcategorylist"]
        }
      },
      {
        path: "category/create",
        name: "majorCategoryCreate",
        component: () => import("@/views/major_category/create"),
        meta: {
          title: "添加专业分类",
          activeMenu: "/admin/major/category/list",
          roles: ["adminmajorcategorycreate"]
        },
        hidden: true
      },
      {
        path: "category/edit/:id(\\d+)",
        name: "majorCategoryEdit",
        component: () => import("@/views/major_category/edit"),
        meta: {
          title: "修改专业分类",
          activeMenu: "/admin/major/category/list",
          roles: ["adminmajorcategoryedit"]
        },
        hidden: true
      },
      {
        path: "list",
        name: "majorList",
        component: () => import("@/views/major/index"),
        meta: {
          title: "专业列表",
          activeMenu: "/admin/major/list",
          roles: ["adminmajorlist"]
        }
      },
      {
        path: "create",
        name: "majorCreate",
        component: () => import("@/views/major/create"),
        meta: {
          title: "添加专业",
          activeMenu: "/admin/major/list",
          roles: ["adminmajorcreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/major/edit"),
        name: "majorEdit",
        meta: {
          title: "修改专业",
          activeMenu: "/admin/major/list",
          roles: ["adminmajoredit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/university",
    component: Layout,
    redirect: "/admin/university/list",
    meta: {
      title: "大学",
      icon: "university",
      roles: ["adminuniversitylist"]
    },
    children: [
      {
        path: "list",
        name: "universityList",
        component: () => import("@/views/university/index"),
        meta: {
          title: "大学列表",
          activeMenu: "/admin/university/list",
          roles: ["adminuniversitylist"]
        }
      },
      {
        path: "create",
        name: "universityCreate",
        component: () => import("@/views/university/create"),
        meta: {
          title: "添加大学",
          activeMenu: "/admin/university/list",
          roles: ["adminuniversitycreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/university/edit"),
        name: "universityEdit",
        meta: {
          title: "修改大学",
          activeMenu: "/admin/university/list",
          roles: ["adminuniversityedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/label",
    component: Layout,
    redirect: "/admin/label/list",
    meta: {
      title: "标签",
      icon: "university",
      roles: ["adminlabellist"]
    },
    children: [
      {
        path: "list",
        name: "labelList",
        component: () => import("@/views/label/index"),
        meta: {
          title: "标签列表",
          activeMenu: "/admin/label/list",
          roles: ["adminlabellist"]
        }
      },
      {
        path: "create",
        name: "labelCreate",
        component: () => import("@/views/label/create"),
        meta: {
          title: "添加标签",
          activeMenu: "/admin/label/list",
          roles: ["adminlabelcreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/label/edit"),
        name: "labelEdit",
        meta: {
          title: "修改大学标签",
          activeMenu: "/admin/label/list",
          roles: ["adminlabeledit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/college-level",
    component: Layout,
    redirect: "/admin/label/list",
    meta: {
      title: "分数段位",
      icon: "university",
      roles: ["admincollegelevellist"]
    },
    children: [
      {
        path: "list",
        name: "collegeLevelList",
        component: () => import("@/views/college_level/index"),
        meta: {
          title: "分数段位列表",
          activeMenu: "/admin/college-level/list",
          roles: ["admincollegelevellist"]
        }
      },
      {
        path: "create",
        name: "collegeLevelCreate",
        component: () => import("@/views/college_level/create"),
        meta: {
          title: "添加分数段位",
          activeMenu: "/admin/college-level/list",
          roles: ["admincollegelevelcreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/college_level/edit"),
        name: "collegeLevelEdit",
        meta: {
          title: "修改分数段位",
          activeMenu: "/admin/college-level/list",
          roles: ["admincollegeleveledit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/college",
    component: Layout,
    redirect: "/admin/college/list",
    meta: {
      title: "招生院校",
      icon: "university",
      roles: ["admincollegelist"]
    },
    children: [
      {
        path: "list",
        name: "collegeList",
        component: () => import("@/views/college/index"),
        meta: {
          title: "招生院校列表",
          activeMenu: "/admin/college/list",
          roles: ["admincollegelist"]
        }
      },
      {
        path: "create",
        name: "collegeCreate",
        component: () => import("@/views/college/create"),
        meta: {
          title: "添加招生院校",
          activeMenu: "/admin/college/list",
          roles: ["admincollegecreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/college/edit"),
        name: "collegeEdit",
        meta: {
          title: "修改招生院校",
          activeMenu: "/admin/college/list",
          roles: ["admincollegeedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/rank",
    component: Layout,
    redirect: "/admin/rank/list",
    meta: { title: "位次", icon: "rank", roles: ["adminranklist"] },
    children: [
      {
        path: "list",
        name: "rankList",
        component: () => import("@/views/rank/index"),
        meta: {
          title: "位次列表",
          activeMenu: "/admin/rank/list",
          roles: ["adminranklist"]
        }
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/rank/edit"),
        name: "rankEdit",
        meta: {
          title: "修改位次",
          activeMenu: "/admin/rank/list",
          roles: ["adminrankedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/admission-data",
    component: Layout,
    redirect: "/admin/admission-data/list",
    meta: {
      title: "录取数据",
      icon: "admission",
      roles: ["adminadmissiondatalist"]
    },
    children: [
      {
        path: "list",
        name: "admissionDataList",
        component: () => import("@/views/admission_data/index"),
        meta: {
          title: "专业录取数据列表",
          activeMenu: "/admin/admission-data/list",
          roles: ["adminadmissiondatalist"]
        }
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/admission_data/edit"),
        name: "admissionDataEdit",
        meta: {
          title: "修改录取数据",
          activeMenu: "/admin/admission-data/list",
          roles: ["adminadmissiondataedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/intention-test-question",
    component: Layout,
    redirect: "/admin/intention-test-question/list",
    meta: {
      title: "意向测试题",
      icon: "question",
      roles: ["adminintentiontestquestionlist"]
    },
    children: [
      {
        path: "list",
        name: "intentionTestQuestionList",
        component: () => import("@/views/intention_test_question/index"),
        meta: {
          title: "意向测试题列表",
          activeMenu: "/admin/intention-test-question/list",
          roles: ["adminintentiontestquestionlist"]
        }
      },
      {
        path: "create",
        component: () => import("@/views/intention_test_question/create"),
        name: "intentionTestQuestionCreate",
        meta: {
          title: "添加测试题",
          activeMenu: "/admin/intention-test-question/list",
          roles: ["adminintentiontestquestionedit"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/intention_test_question/edit"),
        name: "intentionTestQuestionEdit",
        meta: {
          title: "修改测试题",
          activeMenu: "/admin/intention-test-question/list",
          roles: ["adminintentiontestquestionedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/region",
    component: Layout,
    redirect: "/admin/region/list",
    meta: { title: "区域", icon: "region", roles: ["adminregionlist"] },
    children: [
      {
        path: "list",
        name: "regionList",
        component: () => import("@/views/region/index"),
        meta: {
          title: "区域列表",
          activeMenu: "/admin/region/list",
          roles: ["adminregionlist"]
        }
      },
      {
        path: "create",
        component: () => import("@/views/region/create"),
        name: "regionCreate",
        meta: {
          title: "添加区域",
          activeMenu: "/admin/region/list",
          roles: ["adminregioncreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/region/edit"),
        name: "regionEdit",
        meta: {
          title: "修改区域",
          activeMenu: "/admin/region/list",
          roles: ["adminregionedit"]
        },
        hidden: true
      },
      {
        path: "children",
        //component: () => import("@/views/region/index"),
        name: "regionChildren",
        meta: {
          title: "子区域",
          activeMenu: "/admin/region/list",
          roles: ["adminregionchildren"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/enrollment",
    component: Layout,
    redirect: "/admin/enrollment/list",
    meta: {
      title: "招生录取数据",
      icon: "admission_university",
      roles: ["adminenrollmentlist"]
    },
    children: [
      {
        path: "list",
        name: "enrollmentList",
        component: () => import("@/views/enrollment/index"),
        meta: {
          title: "招生录取数据列表",
          activeMenu: "/admin/enrollment/list",
          roles: ["adminenrollmentlist"]
        }
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/enrollment/edit"),
        name: "enrollmentEdit",
        meta: {
          title: "招生录取数据修改",
          activeMenu: "/admin/enrollment/edit",
          roles: ["adminenrollmentedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/student-score",
    component: Layout,
    redirect: "/admin/student-score/list",
    meta: {
      title: "学生成绩",
      icon: "grade",
      roles: ["adminstudentscorelist"]
    },
    children: [
      {
        path: "list",
        name: "studentScoreList",
        component: () => import("@/views/student_score/index"),
        meta: {
          title: "学生成绩列表",
          activeMenu: "/admin/student-score/list",
          roles: ["adminstudentscorelist"]
        }
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/student_score/edit"),
        name: "studentScoreEdit",
        meta: {
          title: "修改学生成绩",
          activeMenu: "/admin/student-score/list",
          roles: ["adminstudentscoreedit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/enrollment-plan",
    component: Layout,
    redirect: "/admin/enrollment-plan/list",
    meta: {
      title: "招生计划",
      icon: "enrollment_plan",
      roles: ["adminenrollmentplanlist"]
    },
    children: [
      {
        path: "list",
        name: "enrollmentPlanList",
        component: () => import("@/views/enrollment_plan/index"),
        meta: {
          title: "招生计划列表",
          activeMenu: "/admin/enrollment-plan/list",
          roles: ["adminenrollmentplanlist"]
        }
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/enrollment_plan/edit"),
        name: "enrollmentPlanEdit",
        meta: {
          title: "招生计划修改",
          activeMenu: "/admin/enrollment-plan/list",
          roles: ["adminenrollmentplanedit"]
        },
        hidden: true
      }
    ]
  },
  {
    path: "/admin/article",
    component: Layout,
    redirect: "/admin/article/list",
    meta: {
      title: "文章列表",
      icon: "article",
      roles: ["adminarticlelist"]
    },
    children: [
      {
        path: "list",
        name: "articleList",
        component: () => import("@/views/article/index"),
        meta: {
          title: "文章列表",
          activeMenu: "/admin/article/list",
          roles: ["adminarticlelist"]
        }
      },
      {
        path: "create",
        name: "articleCreate",
        component: () => import("@/views/article/create"),
        meta: {
          title: "添加文章",
          activeMenu: "/admin/article/list",
          roles: ["adminarticlecreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/article/edit"),
        name: "articleEdit",
        meta: {
          title: "修改文章",
          activeMenu: "/admin/article/list",
          roles: ["adminarticleedit"]
        },
        hidden: true
      },
      {
        path: "category/list",
        name: "categoryList",
        component: () => import("@/views/category/index"),
        meta: {
          title: "文章分类",
          activeMenu: "/admin/article/category/list",
          roles: ["adminarticlecategorylist"]
        }
      },
      {
        path: "category/create",
        name: "categoryCreate",
        component: () => import("@/views/category/create"),
        meta: {
          title: "添加文章分类",
          activeMenu: "/admin/article/category/list",
          roles: ["adminarticlecategorycreate"]
        },
        hidden: true
      },
      {
        path: "category/edit/:id(\\d+)",
        component: () => import("@/views/category/edit"),
        name: "categorylEdit",
        meta: {
          title: "修改文章分类",
          activeMenu: "/admin/article/category/list",
          roles: ["adminarticlecategoryedit"]
        },
        hidden: true
      }
    ]
  },
  {
    path: "/admin/my-university",
    component: Layout,
    //redirect: "/admin/my-university",
    meta: {
      title: "我的大学",
      icon: "university",
      roles: ["adminmyuniversityedit"]
    },
    children: [
      {
        path: "edit",
        component: () => import("@/views/my_university/edit"),
        name: "myUniversityEdit",
        meta: {
          title: "我的大学"
        },
        hidden: false
      }
    ]
  },

  {
    path: "/admin/feedback",
    component: Layout,
    redirect: "/admin/feedback/list",
    meta: { title: "用户反馈", icon: "feedback", roles: ["adminfeedbacklist"] },
    children: [
      {
        path: "list",
        name: "feedbackList",
        component: () => import("@/views/feedback/index"),
        meta: {
          title: "用户反馈列表",
          activeMenu: "/admin/feedback/list",
          roles: ["adminfeedbacklist"]
        }
      }
    ]
  },

  {
    path: "/admin/users",
    component: Layout,
    redirect: "/admin/users/list",
    meta: { title: "会员", icon: "user", roles: ["userlist"] },
    children: [
      {
        path: "list",
        name: "usersList",
        component: () => import("@/views/user/index"),
        meta: {
          title: "会员列表",
          activeMenu: "/admin/users/list",
          roles: ["userlist"]
        }
      }
    ]
  },

  {
    path: "/admin/match-university",
    component: Layout,
    redirect: "/admin/match-university/list",
    meta: {
      title: "保录学生",
      icon: "student",
      roles: ["adminmatchuniversitylist"]
    },
    children: [
      {
        path: "list",
        name: "matchUniversityList",
        component: () => import("@/views/match_university/index"),
        meta: {
          title: "保录学生列表",
          activeMenu: "/admin/match-university/list",
          roles: ["adminmatchuniversitylist"]
        }
      }
    ]
  },

  {
    path: "/admin/high-school",
    component: Layout,
    redirect: "/admin/high-school/list",
    meta: {
      title: "高中",
      icon: "student",
      roles: ["adminhighschoollist"]
    },
    children: [
      {
        path: "list",
        name: "highSchoolList",
        component: () => import("@/views/high_school/index"),
        meta: {
          title: "高中列表",
          activeMenu: "/admin/high-school/list",
          roles: ["adminhighschoollist"]
        }
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/high_school/edit"),
        name: "highSchoolEdit",
        meta: {
          title: "修改高中信息",
          activeMenu: "/admin/high-school/list",
          roles: ["adminhighschooledit"]
        },
        hidden: true
      }
    ]
  },

  {
    path: "/admin/high-school-class",
    component: Layout,
    redirect: "/admin/high-school-class/list",
    meta: {
      title: "高中班级",
      icon: "student",
      roles: ["adminhighschoolclasslist"]
    },
    children: [
      {
        path: "list",
        name: "highSchoolClassList",
        component: () => import("@/views/high_school_class/index"),
        meta: {
          title: "高中班级列表",
          activeMenu: "/admin/high-school-class/list",
          roles: ["adminhighschoolclasslist"]
        }
      },
      {
        path: "create",
        component: () => import("@/views/high_school_class/create"),
        name: "highSchoolClassCreate",
        meta: {
          title: "新增高中班级",
          activeMenu: "/admin/high-school-class/list",
          roles: ["adminhighschoolclasscreate"]
        },
        hidden: true
      },
      {
        path: "edit/:id(\\d+)",
        component: () => import("@/views/high_school_class/edit"),
        name: "highSchoolClassEdit",
        meta: {
          title: "修改高中班级信息",
          activeMenu: "/admin/high-school-class/list",
          roles: ["adminhighschoolclassedit"]
        },
        hidden: true
      }
    ]
  },


  {
    path: "/admin/site-config",
    component: Layout,
    redirect: "/admin/site-config/edit",
    meta: {
      title: "网站配置",
      icon: "config",
      roles: ["adminsiteconfigedit"]
    },
    children: [
      {
        path: "edit",
        component: () => import("@/views/site_config/edit"),
        name: "siteConfigEdit",
        meta: {
          title: "网站配置",
          activeMenu: "/admin/site-config/edit",
          roles: ["adminsiteconfigedit"]
        },
        hidden: true
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: "*", redirect: "/404", hidden: true }
];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
